package MyTest;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class T11 {
    public static int getValue(String str){
        // 是数组
        boolean isArray = false;
        boolean isChar = false;
        for(int i=0; i<str.length(); i++){
            if(str.charAt(i) == '[' || str.charAt(i) == ']'){
                isArray = true;
                break;
            }
            if(str.charAt(i)>='A' && str.charAt(i)<='c'){
                isChar = true;
            }
        }
        if(isArray){
            String regex = "\\[(.*?)]";
            Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(str);
            int total = 1;
            while (matcher.find()) {
                total *= Integer.valueOf(matcher.group(1));
            }
            return total;
        }else if(isChar){
            return 1;
        }

        return 0;
    }
    public static void main(String[] args) {
        String ss = "刘德华刘德陈冠希九龙湾周星驰理查德刘德华";
        System.out.println(ss.length());
        String[] res = ss.split("刘德华");
        int afterLength = 0;
        for(String r : res){
            afterLength += r.length();
        }
        System.out.println(afterLength);
        System.out.println((ss.length() - afterLength) / "刘德华".length());

    }
}
